﻿using Basic.HrModel.DB;
using Basic.HrRemoteModel.Holidays.Model;
using WeDonekRpc.Helper;
using WeDonekRpc.Helper.IdGenerator;
using WeDonekRpc.SqlSugar;

namespace Basic.HrDAL.Repository
{
    internal class HolidaysDAL : BasicDAL<DBHolidays, long>, IHolidaysDAL
    {
        public HolidaysDAL ( IRepository<DBHolidays> basicDAL ) : base(basicDAL, "holidays")
        {
        }

        public void Add ( HolidaysAdd add )
        {
            DBHolidays data = new DBHolidays
            {
                Id = IdentityHelper.CreateId(),
                Date = add.Date,
                IsWork = add.IsWork,
                LimitSex = add.LimitSex,
                Show = add.Show,
                TimeSpan = add.TimeSpan
            };
            this._BasicDAL.Insert(data);
        }
        public void Adds ( HolidaysAdd[] adds )
        {
            this._BasicDAL.Insert(adds.ConvertAll(a =>
            {
                return new DBHolidays
                {
                    Id = IdentityHelper.CreateId(),
                    Date = a.Date,
                    IsWork = a.IsWork,
                    LimitSex = a.LimitSex,
                    Show = a.Show,
                    TimeSpan = a.TimeSpan
                };
            }));
        }
    }
}
